Get the gui ready for Qt5 while maintaining support for Qt4.
authortsteven4 <tsteven4@gmail.com>
Thu, 12 Sep 2013 02:52:40 +0000 (02:52 +0000)
committertsteven4 <tsteven4@gmail.com>
Thu, 12 Sep 2013 02:52:40 +0000 (02:52 +0000)
gpsbabel/gui/app.pro
gpsbabel/gui/main.cc
gpsbabel/gui/makelinuxdist.sh.in
gpsbabel/gui/optionsdlg.cc

index bd14d2030fe2ef604b919c928396ab5bc091752e..3e933875d7bf6c3ae3ab949502205cc2dc227d36 100755 (executable)
@@ -12,8 +12,13 @@ macx:DEFINES += HAVE_CONFIG_H
 ICON = images/appicon.icns
 
 QT += network \
-    xml \
-    webkit \
+      xml \
+      webkit
+
+greaterThan(QT_MAJOR_VERSION, 4) {
+  QT += widgets \
+        webkitwidgets
+}
 
 unix:DESTDIR = objects
 unix:MOC_DIR = objects
index 0e50b6ed76af9c12039e11707a80b54a14e844f6..62393fbef5110f44a7f1f8ebf06ef12788d97d5e 100644 (file)
@@ -26,6 +26,7 @@
 #include <QCoreApplication>
 #include <QLibraryInfo>
 #include <QIcon>
+#include <QTextCodec>
 
 #include "mainwindow.h"
 #include "gmapdlg.h"
@@ -43,6 +44,15 @@ const char *pathSeparator = ":";
 //------------------------------------------------------------------------
 int main(int argc, char**argv)
 {
+#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
+  // Qt 5.0 uses QString::fromUtf8 to convert from character pointers 
+  // and QBytreArrays to QStrings while previous version of Qt used 
+  // QString::fromAscii.  QString::fromAscii used the codec set
+  // by QTextCode::setCodecForCStrings.
+  // This makes the conversion consistent between Qt4 and Qt5.
+  QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
+#endif
+
   QApplication *app;
   app = new QApplication(argc, argv);
   app->setWindowIcon(QIcon(":/images/appicon.png"));
index bd1f8722194b40cfb6ff8df868f5d53e99baf858..72707f7a02a133ac46d90465a5f7fa963bc6fd68 100644 (file)
@@ -20,7 +20,19 @@ done
 #cp `ldd objects/gpsbabelfe-bin  | grep libaudio   |awk '{print $3}'` $DISTDIR
 
 cp -r $QT_INSTALL_PLUGINS/imageformats $DISTDIR/plugins
-cp -r $QT_INSTALL_PLUGINS/codecs $DISTDIR/plugins
+if [ -e $QT_INSTALL_PLUGINS/codecs ]
+then
+  cp -r $QT_INSTALL_PLUGINS/codecs $DISTDIR/plugins
+else
+  echo "Warning: $QT_INSTALL_PLUGINS/codecs not found, perhaps this is normal for Qt5"
+fi
+if [ -e $QT_INSTALL_PLUGINS/platforms ]
+then
+#  we need at least platforms/libqxcb.so
+  cp -r $QT_INSTALL_PLUGINS/platforms $DISTDIR/plugins
+else
+  echo "Wanring: $QT_INSTALL_PLUGINS/platforms not found, this is normal for Qt4"
+fi
 cp $QT_INSTALL_TRANSLATIONS/qt_*.qm $DISTDIR/translations/
 
 # copy the compiled translations
index b6564aaff12a73851862ca43915cb3ab87c95365..497945c54330a3b2d404b438c739b7d5236725ab 100644 (file)
@@ -94,7 +94,7 @@ OptionsDlg::OptionsDlg(QWidget*parent,  const QString &fmtName, QList<FormatOpti
     QHBoxLayout *horizontalLayout = new QHBoxLayout();
 
     QCheckBox *checkBox = new QCheckBox(this);
-    checkBox->setText(tr(options[k].getDescription().toAscii().data()));
+    checkBox->setText(options[k].getDescription());
     horizontalLayout->addWidget(checkBox);
     checkBox->setChecked(options[k].getSelected());
     //checkBox->setWhatsThis(options[k].getHtml());